<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="text/javascript">
    let arr = [1, 3, 5, 7, 9]
    let arr2 = [2, 4, 6, 8, 10]
    console.log(...arr)//展开一个数组
    let arr3 = [...arr, ...arr2]
    console.log(...arr3)//展开一个数组

    function sum(...numbers) {
        console.log('@numbers', numbers)
        return numbers.reduce((previousValue, currentValue) => {
            return previousValue + currentValue
        })
    }

    console.log(sum(1, 2, 3, 4))

    //构造字面量数组时使用展开语法
    let person = {name: 'tom', age: 19}
    let person2 = {...person}
    //console.log(...person) //报错，展开运算符不能展开对象
    person.name = 'julia'
    console.log(person2)
    console.log(person)

    //合并
    let person3 = {...person, name: 'jack',address:'地球'}
    console.log(person3)

</script>
</body>
</html>